package com.wayne.structure.array;

/**
 * Find the first non-repeating element in a given array of integers.
 *
 * Examples:
 * Input : -1 2 -1 3 2
 * Output : 3
 * Explanation : The first number that does not repeat is : 3
 * Input : 9 4 9 6 7 4
 * Output : 6
 */
public class ArrayTest2 {

    //思路:循环数组，先拿第一个元素分别跟后面元素比，如果有与之相同的则continue，如果遍历到最后一个元素还没有与之相同的，
    //则返回此元素
    private static void operation(Integer[] source) {
        if (source.length == 0) {
            System.out.println("给定的数组为空");
            return;
        }

        Integer result = null;

        outer : for (int i=0; i<source.length; i++) {
            for (int j=i+1; j<source.length; j++) {
                if (source[i] == source[j]) {
                    continue outer;
                }
//                result =
            }


        }

        if (result == null) {
            System.out.println("给定的数组中不存在不重复的元素");
        } else {
            System.out.println("The first number that does not repeat is : "+result);
        }


    }


    public static void main(String[] args) {
        Integer[] source = {1,4,65,4,8,1,65,9};
        operation(source);
    }

}
